import java.util.Arrays;
import java.util.Random;

/**
 * @Auther: MFM
 * @Date: 2021/7/15 - 07 - 15 - 15:00
 * @version: 1.0
 */

public class Test {
    static class Count {
        public int num = 0;
        public int times = 0;

        public Count(int num) {
            this.num = num;
        }
        @Override
        public String toString() {
            return  num + ":次数" + times;
        }
    }


    public static void main(String[] args) {
        Random random = new Random();
        Count[] nums = {
                new Count(1),new Count(2),new Count(3),new Count(4),new Count(5),new Count(6),new Count(7),new Count(8),new Count(9),new Count(10),
        };
        for (int i = 0; i < 20; i++) {
            //限定了边界是10，但是取值范围 0 - 9 所以需要+1
            int value = random.nextInt(10) + 1;
            for (Count cou : nums) {
                if (value == cou.num) {
                    cou.times++;
                    break;
                }
            }
        }
        System.out.println(Arrays.toString(nums));
    }


}